home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 89 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.9 KB

  1. Path: fido.asd.sgi.com!austern
  2. From: Dan Holmsand <dan@et.se>
  3. Newsgroups: comp.std.c++
  4. Subject: Give operator. a chance
  5. Date: 22 Jan 1996 09:44:26 PST
  6. Organization: Affdrsvdrlden
  7. Approved: austern@isolde.mti.sgi.com
  8. Message-ID: <3102AD11.1663@et.se>
  9. NNTP-Posting-Host: isolde.mti.sgi.com
  10. X-Original-Date: Sun, 21 Jan 1996 22:16:01 +0100
  11. X-Mailer: Mozilla 2.0b6 (WinNT; I)
  12. X-Url: http://dogbert.lbl.gov/~matt/std-c++/policy.html
  13. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  14.     iQBVAwUBMQPNCUy4NqrwXLNJAQGoyQIAoLyGVSD5Dq4K2BkTHgJDynKd/Pjxb9zF
  15.     vMkfirRHP4usBz9cYcbIBPUp9XdxIok36wfcdAfou8jRsM07OXh5jA==
  16.     =diHi
  17. Originator: austern@isolde.mti.sgi.com
  18.  
  19. Is operator.() banned from the standards discussion?
  20.  
  21. Such a creature would sure be nice to have, given the STL 
  22. containers. Suppose that you have a list<string>, and lots of 
  23. code looking like
  24.  
  25.   typedef list<string> stringlist;
  26.   /* ....... */
  27.   for (stringlist::iterator i = l.begin(); i != l.end(); i++)
  28.     (*i).append(".");
  29.  
  30. Then you decide that you want to put something else into the 
  31. list. If you decide not to derive from string (e.g. using a smart 
  32. pointer instead), there is no alternative to rewriting all the 
  33. functions refering to type stringlist.
  34.  
  35. The only way to retain flexibility now, as far as I can see, is 
  36. to refrain from using constructs like (*i).function(), using 
  37. smart pointer imitating wrappers and (*i)->function() 
  38. consequently instead. But this is kind of messy...
  39.  
  40. Ideally, operator.() should allow you to have all the things 
  41. inheritance allows you to have, except for storage. I.e. a class 
  42. with operator.() should behave just as its "base class", but be 
  43. allowed to override suitable functions.
  44.  
  45. Why isn't this possible? What's the catch?
  46.  
  47. Dan Holmsand
  48. dan@et.se
  49. ---
  50. [ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  51.   Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  52.   is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
  53.